<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>01 字符实体与语义标签 | HasakWebBlog</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="/favicon.ico">
    <meta name="description" content="hasak">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.a5a0d673.css" as="style"><link rel="preload" href="/assets/js/app.c7915c77.js" as="script"><link rel="preload" href="/assets/js/3.f80332a6.js" as="script"><link rel="preload" href="/assets/js/1.5cffa4a1.js" as="script"><link rel="preload" href="/assets/js/11.c5238d8f.js" as="script"><link rel="prefetch" href="/assets/js/10.02ae8499.js"><link rel="prefetch" href="/assets/js/12.be21fd80.js"><link rel="prefetch" href="/assets/js/13.bd684308.js"><link rel="prefetch" href="/assets/js/14.b5f9fc77.js"><link rel="prefetch" href="/assets/js/15.318683dc.js"><link rel="prefetch" href="/assets/js/16.74f9d94e.js"><link rel="prefetch" href="/assets/js/17.cd1e6d69.js"><link rel="prefetch" href="/assets/js/18.901e5492.js"><link rel="prefetch" href="/assets/js/19.417d2070.js"><link rel="prefetch" href="/assets/js/20.39ec66a2.js"><link rel="prefetch" href="/assets/js/21.fbf1aaf8.js"><link rel="prefetch" href="/assets/js/22.736aeb98.js"><link rel="prefetch" href="/assets/js/23.abcdc310.js"><link rel="prefetch" href="/assets/js/24.26658596.js"><link rel="prefetch" href="/assets/js/25.40bdc691.js"><link rel="prefetch" href="/assets/js/26.29ac009b.js"><link rel="prefetch" href="/assets/js/27.edc6afbf.js"><link rel="prefetch" href="/assets/js/28.b9c1065e.js"><link rel="prefetch" href="/assets/js/29.b46f8f9e.js"><link rel="prefetch" href="/assets/js/30.6839ae7e.js"><link rel="prefetch" href="/assets/js/31.85913f4e.js"><link rel="prefetch" href="/assets/js/32.098b21df.js"><link rel="prefetch" href="/assets/js/33.faced894.js"><link rel="prefetch" href="/assets/js/34.239b19e7.js"><link rel="prefetch" href="/assets/js/35.5c8a8406.js"><link rel="prefetch" href="/assets/js/36.46f0ebac.js"><link rel="prefetch" href="/assets/js/37.2456f410.js"><link rel="prefetch" href="/assets/js/38.b76624ee.js"><link rel="prefetch" href="/assets/js/39.64ecef14.js"><link rel="prefetch" href="/assets/js/4.7d7a493e.js"><link rel="prefetch" href="/assets/js/40.a1304a44.js"><link rel="prefetch" href="/assets/js/41.f98208ce.js"><link rel="prefetch" href="/assets/js/42.f0be4a4c.js"><link rel="prefetch" href="/assets/js/43.1a46f61e.js"><link rel="prefetch" href="/assets/js/44.d579b00f.js"><link rel="prefetch" href="/assets/js/45.8e8ea47a.js"><link rel="prefetch" href="/assets/js/46.1b194721.js"><link rel="prefetch" href="/assets/js/47.994c7d71.js"><link rel="prefetch" href="/assets/js/48.f17a641c.js"><link rel="prefetch" href="/assets/js/49.0d9ea06f.js"><link rel="prefetch" href="/assets/js/5.176296fc.js"><link rel="prefetch" href="/assets/js/50.e36885a9.js"><link rel="prefetch" href="/assets/js/51.64538ee2.js"><link rel="prefetch" href="/assets/js/52.1fd24c2e.js"><link rel="prefetch" href="/assets/js/53.967b1458.js"><link rel="prefetch" href="/assets/js/54.05b15a98.js"><link rel="prefetch" href="/assets/js/55.3c78b9d4.js"><link rel="prefetch" href="/assets/js/56.8d130c30.js"><link rel="prefetch" href="/assets/js/57.0008c022.js"><link rel="prefetch" href="/assets/js/58.4b49a382.js"><link rel="prefetch" href="/assets/js/59.8bb182dc.js"><link rel="prefetch" href="/assets/js/6.90835ce9.js"><link rel="prefetch" href="/assets/js/60.93235335.js"><link rel="prefetch" href="/assets/js/61.78370acd.js"><link rel="prefetch" href="/assets/js/62.1144f314.js"><link rel="prefetch" href="/assets/js/63.7fb72cd2.js"><link rel="prefetch" href="/assets/js/64.de8ba1be.js"><link rel="prefetch" href="/assets/js/65.cefa274d.js"><link rel="prefetch" href="/assets/js/66.32ad44bf.js"><link rel="prefetch" href="/assets/js/67.558c356c.js"><link rel="prefetch" href="/assets/js/68.15a3af19.js"><link rel="prefetch" href="/assets/js/69.b1b26c0a.js"><link rel="prefetch" href="/assets/js/7.2c075495.js"><link rel="prefetch" href="/assets/js/70.cb9b8e94.js"><link rel="prefetch" href="/assets/js/71.e371986a.js"><link rel="prefetch" href="/assets/js/72.a8af9117.js"><link rel="prefetch" href="/assets/js/73.dcc5a1af.js"><link rel="prefetch" href="/assets/js/74.803a909b.js"><link rel="prefetch" href="/assets/js/75.8129f8f6.js"><link rel="prefetch" href="/assets/js/76.ffcb07fc.js"><link rel="prefetch" href="/assets/js/8.9b4cfefe.js"><link rel="prefetch" href="/assets/js/9.e529cf11.js">
    <link rel="stylesheet" href="/assets/css/0.styles.a5a0d673.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-7dd95ae2><div data-v-7dd95ae2><div class="password-shadow password-wrapper-out" style="display:none;" data-v-59e6cb88 data-v-7dd95ae2 data-v-7dd95ae2><h3 class="title" data-v-59e6cb88>HasakWebBlog</h3> <p class="description" data-v-59e6cb88>hasak</p> <label id="box" class="inputBox" data-v-59e6cb88><input type="password" value="" data-v-59e6cb88> <span data-v-59e6cb88>Konck! Knock!</span> <button data-v-59e6cb88>OK</button></label> <div class="footer" data-v-59e6cb88><span data-v-59e6cb88><i class="iconfont reco-theme" data-v-59e6cb88></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-59e6cb88>vuePress-theme-reco</a></span> <span data-v-59e6cb88><i class="iconfont reco-copyright" data-v-59e6cb88></i> <a data-v-59e6cb88><span data-v-59e6cb88>hasak</span>
          
        <span data-v-59e6cb88>2022 - </span>
        2023
      </a></span></div></div> <div class="hide" data-v-7dd95ae2><header class="navbar" data-v-7dd95ae2><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo.png" alt="HasakWebBlog" class="logo"> <span class="site-name">HasakWebBlog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      前端学习
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/HTML5&amp;CSS3/" class="nav-link"><i class="undefined"></i>
  HTML5&amp;CSS3
</a></li><li class="dropdown-item"><!----> <a href="/categories/Javascript/" class="nav-link"><i class="undefined"></i>
  Javascript
</a></li><li class="dropdown-item"><!----> <a href="/categories/Node/" class="nav-link"><i class="undefined"></i>
  Node
</a></li><li class="dropdown-item"><!----> <a href="/categories/VUE/" class="nav-link"><i class="undefined"></i>
  VUE
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tags
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间轴
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      联系我
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/hasakxu" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-7dd95ae2></div> <aside class="sidebar" data-v-7dd95ae2><div class="personal-info-wrapper" data-v-1fad0c41 data-v-7dd95ae2><img src="/dog.png" alt="author-avatar" class="personal-img" data-v-1fad0c41> <h3 class="name" data-v-1fad0c41>
    hasak
  </h3> <div class="num" data-v-1fad0c41><div data-v-1fad0c41><h3 data-v-1fad0c41>66</h3> <h6 data-v-1fad0c41>Articles</h6></div> <div data-v-1fad0c41><h3 data-v-1fad0c41>5</h3> <h6 data-v-1fad0c41>Tags</h6></div></div> <ul class="social-links" data-v-1fad0c41></ul> <hr data-v-1fad0c41></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      前端学习
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/HTML5&amp;CSS3/" class="nav-link"><i class="undefined"></i>
  HTML5&amp;CSS3
</a></li><li class="dropdown-item"><!----> <a href="/categories/Javascript/" class="nav-link"><i class="undefined"></i>
  Javascript
</a></li><li class="dropdown-item"><!----> <a href="/categories/Node/" class="nav-link"><i class="undefined"></i>
  Node
</a></li><li class="dropdown-item"><!----> <a href="/categories/VUE/" class="nav-link"><i class="undefined"></i>
  VUE
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tags
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间轴
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      联系我
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/hasakxu" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>HTML5&amp;CSS3 学习</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/blogs/基础/html/20221107html01.html" class="active sidebar-link">01 字符实体与语义标签</a></li><li><a href="/blogs/基础/html/20221107html02.html" class="sidebar-link">02 CSS语法与选择器</a></li><li><a href="/blogs/基础/html/20221110html03.html" class="sidebar-link">03 样式继承与其他概念</a></li><li><a href="/blogs/基础/html/20221110html04.html" class="sidebar-link">04 盒模型</a></li><li><a href="/blogs/基础/html/20221110html05.html" class="sidebar-link">05 盒模型补充</a></li><li><a href="/blogs/基础/html/20221113html06.html" class="sidebar-link">06 浮动</a></li><li><a href="/blogs/基础/html/20221113html07.html" class="sidebar-link">07 高度塌陷与BFC</a></li><li><a href="/blogs/基础/html/20221113html08.html" class="sidebar-link">08 定位</a></li><li><a href="/blogs/基础/html/20221115html09.html" class="sidebar-link">09 字体</a></li><li><a href="/blogs/基础/html/20221115html10.html" class="sidebar-link">10 背景</a></li><li><a href="/blogs/基础/html/20221115html11.html" class="sidebar-link">11 雪碧图和渐变</a></li><li><a href="/blogs/基础/html/20221115html12.html" class="sidebar-link">12 表格</a></li><li><a href="/blogs/基础/html/20221115html13.html" class="sidebar-link">13 过渡与动画</a></li><li><a href="/blogs/基础/html/20221115html14.html" class="sidebar-link">14 变形：平移、旋转与缩放</a></li><li><a href="/blogs/基础/html/20221115html15.html" class="sidebar-link">15 LESS简介</a></li><li><a href="/blogs/基础/html/20221115html16.html" class="sidebar-link">16 弹性盒简介</a></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-59e6cb88 data-v-7dd95ae2><h3 class="title" data-v-59e6cb88>01 字符实体与语义标签</h3> <!----> <label id="box" class="inputBox" data-v-59e6cb88><input type="password" value="" data-v-59e6cb88> <span data-v-59e6cb88>Konck! Knock!</span> <button data-v-59e6cb88>OK</button></label> <div class="footer" data-v-59e6cb88><span data-v-59e6cb88><i class="iconfont reco-theme" data-v-59e6cb88></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-59e6cb88>vuePress-theme-reco</a></span> <span data-v-59e6cb88><i class="iconfont reco-copyright" data-v-59e6cb88></i> <a data-v-59e6cb88><span data-v-59e6cb88>hasak</span>
          
        <span data-v-59e6cb88>2022 - </span>
        2023
      </a></span></div></div> <div data-v-7dd95ae2><div data-v-7dd95ae2><main class="page" style="padding-right:0;"><section style="display:;"><div class="page-title"><h1 class="title">01 字符实体与语义标签</h1> <div data-v-8a445198><i class="iconfont reco-account" data-v-8a445198><span data-v-8a445198>hasak</span></i> <i class="iconfont reco-date" data-v-8a445198><span data-v-8a445198>6/15/2022</span></i> <!----> <i class="tags iconfont reco-tag" data-v-8a445198><span class="tag-item" data-v-8a445198>HTML</span></i></div></div> <div class="theme-reco-content content__default"><h1 id="_01-字符实体与语义标签"><a href="#_01-字符实体与语义标签" class="header-anchor">#</a> 01 字符实体与语义标签</h1> <h2 id="_1-字符实体"><a href="#_1-字符实体" class="header-anchor">#</a> 1. 字符实体</h2> <p>有些时候，HTML中不能直接书写一些特殊符号，如</p> <ul><li>多个连续的空格（在网页中编写的多个空格默认情况会自动被浏览器解析为一个空格）</li> <li>字符两侧的大于小于号（可能会被认为是标签并解析）</li></ul> <p>因此，我们在网页中书写这些特殊的符号时，需要使用html中的实体（转义字符）</p> <ul><li>实体的语法：<code>&amp;实体的名字；</code></li></ul> <table><thead><tr><th>实体名称</th> <th>显示结果</th> <th>描述</th></tr></thead> <tbody><tr><td><code>&amp;nbsp;</code></td> <td><code></code></td> <td>空格</td></tr> <tr><td><code>&amp;gt;</code></td> <td>&gt;</td> <td>大于号</td></tr> <tr><td><code>&amp;lt;</code></td> <td>&lt;</td> <td>小于号</td></tr> <tr><td><code>&amp;amp;</code></td> <td>&amp;</td> <td>与</td></tr> <tr><td><code>&amp;copy;</code></td> <td>©</td> <td>版权</td></tr> <tr><td><code>&amp;reg;</code></td> <td>®</td> <td>注册商标</td></tr> <tr><td><code>&amp;trade;</code></td> <td>™</td> <td>商标</td></tr> <tr><td><code>&amp;times;</code></td> <td>×</td> <td>乘号</td></tr> <tr><td><code>&amp;divide;</code></td> <td>÷</td> <td>除号</td></tr> <tr><td><code>&amp;iquest;</code></td> <td>¿</td> <td>倒问号</td></tr></tbody></table> <p>更多的字符实体，可以参考：<a href="https://www.w3school.com.cn/html/html_entities.asp" target="_blank" rel="noopener noreferrer">HTML字符实体<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="_2-meta标签"><a href="#_2-meta标签" class="header-anchor">#</a> 2. meta标签</h2> <p>meta主要用于设置网页中的一些元数据，元数据不是给用户看的</p> <ul><li><p>charset： 指定网页的字符集</p></li> <li><p>name： 指定的数据名称</p> <blockquote><blockquote><ul><li>keywords: 表示网站的关键字，可以同时指定多个关键字，关键字之间使用<code>,</code>隔开</li> <li>description： 表示网站的描述信息</li></ul></blockquote></blockquote> <ul><li>content: 指定的数据内容，会作为搜索结果超链接上的文字显示。</li></ul> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>utf8<span class="token punctuation">&quot;</span></span> <span class="token attr-name">version</span> <span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">'</span>1<span class="token punctuation">'</span></span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>viewport<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>width=device-width, initial-scale=1.0, user-scalable=yes <span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>description<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>msg<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Keywords<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>msg<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p><code>http-equiv</code></p> <blockquote><ul><li>如果设置了<code>http-equiv</code>属性，<code>&lt;meta&gt;</code>元素就是一个pragma指令，提供的信息相当于一个类似名称的HTTP头所能提供的信息</li> <li>点击<code>http-equiv</code>的链接，查看其更详细的信息</li></ul> <blockquote><ul><li><p>content-security-policy: 允许页面作者为当前页面定义一个<em>内容策略</em>。内容策略主要指定允许的服务器来源和脚本端点，这有利于防范跨站脚本攻击。</p></li> <li><p>content-type: 声明文档的<em>MIME类型和字符编码</em>。如果指定，content属性必须有“text/html；charset=utf-8”的值。这相当于一个指定了charset属性的<code>&lt;meta&gt;</code>元素，并对文档中的位置有同样的限制。注意：只能在使用<code>text/html</code>的文档中使用，不能在使用<code>xml MIME</code>类型的文档中使用。</p></li> <li><p><code>default-style</code>：设置默认的CSS样式表集的名称。</p></li> <li><p><code>x-ua-compatible</code>: 如果指定，内容属性必须有“<code>IE=edge</code>”的值。用户代理被要求忽略这个pragma。</p></li> <li><p><code>refresh</code>： 该指令指定页面重新加载及重定向的方式</p></li></ul> <blockquote><ul><li>直到页面应该被重新加载的秒数——只有当content属性包含一个正整数时。</li> <li>知道页面重定向到另一个页面的秒数——只有当内容属性包含一个正整数，后面跟着字符串‘<code>;url=</code>’, 以及一个有效的url。</li></ul></blockquote></blockquote></blockquote></li></ul> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>utf-8<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!-- 3s后跳转到百度--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">http-equiv</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>refresh<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>3;url=https://www.baidu.com<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>上述代码对<code>refresh</code>进行测试，发现过了3秒后自动调转到了指定的网站</p> <h2 id="_3-语义标签"><a href="#_3-语义标签" class="header-anchor">#</a> 3.语义标签</h2> <p>在网页中HTML专门用来负责网页的结构所以在使用html标签时，应该关注的是标签的语义，而不是它的样式。</p> <p>这里介绍了部分基本的语义标签，还有些常用的标签放于以后具体讲解。</p> <table><thead><tr><th></th> <th style="text-align:center;">标签</th> <th style="text-align:center;">作用</th> <th style="text-align:center;">描述</th></tr></thead> <tbody><tr><td>块元素</td> <td style="text-align:center;"><code>&lt;h1&gt;</code><br><code>&lt;h2&gt;</code><br><code>&lt;h3&gt;</code><br><code>&lt;h4&gt;</code><br><code>&lt;h5&gt;</code><br><code>&lt;h6&gt;</code><br></td> <td style="text-align:center;">标题</td> <td style="text-align:center;">标题（Heading）是通过 <code>&lt;h1&gt;</code> - <code>&lt;h6&gt;</code>等标签进行定义的。重要性依次递减，<code>&lt;h1&gt;</code>最重要，<code>&lt;h6&gt;</code>最不重要，一般情况下一个页面只会有一个<code>h1</code>。一般的标签用H1-H3</td></tr> <tr><td>Block Element</td> <td style="text-align:center;"><code>&lt;hgroup&gt;</code></td> <td style="text-align:center;">标题组</td> <td style="text-align:center;">多层次的标题，它将一组<code>&lt;h1&gt;</code>~<code>&lt;h6&gt;</code>元素分组</td></tr> <tr><td></td> <td style="text-align:center;"><code>&lt;p&gt;</code></td> <td style="text-align:center;">段落</td> <td style="text-align:center;">页面中的一个段落，由空行或第一个行缩进将相邻的文本分开</td></tr> <tr><td></td> <td style="text-align:center;"><code>&lt;blockquote&gt;</code></td> <td style="text-align:center;">长引文</td> <td style="text-align:center;">用缩进表示所包含文本。可以用<code>cite</code>属性表示引文来源，用<code>&lt;cite&gt;</code>元素表示来源的文本表述</td></tr> <tr><td>行内元素</td> <td style="text-align:center;"><code>&lt;q&gt;</code></td> <td style="text-align:center;">短引文</td> <td style="text-align:center;">用一个简短的内联引号包围文本。大多数浏览器通过在文本周围加上引号来实现。该元素用于不需要段落分割的短引文。</td></tr> <tr><td>inline Element</td> <td style="text-align:center;"><code>&lt;br/&gt;</code></td> <td style="text-align:center;">换行</td> <td style="text-align:center;"></td></tr> <tr><td></td> <td style="text-align:center;"><code>&lt;em&gt;</code></td> <td style="text-align:center;">强调/斜体</td> <td style="text-align:center;">表示强调作用。<code>&lt;em&gt;</code>元素可以嵌套，每一级嵌套表示更高的强调程度<code>&lt;i&gt;</code>元素效果与它相同，不过<code>&lt;i&gt;</code>不属于语义标签</td></tr> <tr><td></td> <td style="text-align:center;"><code>&lt;strong&gt;</code></td> <td style="text-align:center;">重要</td> <td style="text-align:center;">表示重要性、严肃性或紧迫性。浏览器通常粗体字呈现内容<code>&lt;b&gt;</code>元素效果与它相同，不过<code>&lt;b&gt;</code>不属于语义标签</td></tr></tbody></table> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">&gt;</span></span>一级标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">&gt;</span></span>二级标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>hgroup</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">&gt;</span></span>三级标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">&gt;</span></span>四级标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>hgroup</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h5</span><span class="token punctuation">&gt;</span></span>五级标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h5</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h6</span><span class="token punctuation">&gt;</span></span>六级标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h6</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>段落标签<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>段落标签<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>今天天气<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>em</span><span class="token punctuation">&gt;</span></span>真<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>em</span><span class="token punctuation">&gt;</span></span>不错<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
鲁迅说：
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>blockquote</span><span class="token punctuation">&gt;</span></span>
	我没说过这话
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>blockquote</span><span class="token punctuation">&gt;</span></span>
子曰<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>q</span><span class="token punctuation">&gt;</span></span>学而时习之，乐呵乐呵<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>q</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">/&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><h1>一级标题</h1> <h2>二级标题</h2> <hgroup><h3>三级标题</h3> <h4>四级标题</h4></hgroup> <h5>五级标题</h5> <h6>六级标题</h6> <p>段落标签</p> <p>段落标签</p> <p>今天天气<em>真</em>不错</p>
鲁迅说：
<blockquote>
	我没说过这话
</blockquote>
子曰<q>学而时习之，乐呵乐呵</q><br> <h3 id="_3-2-html5提供的新语义元素"><a href="#_3-2-html5提供的新语义元素" class="header-anchor">#</a> 3.2 HTML5提供的新语义元素</h3> <table><thead><tr><th style="text-align:center;">标签</th> <th style="text-align:center;">作用</th> <th style="text-align:left;">描述</th></tr></thead> <tbody><tr><td style="text-align:center;"><code>&lt;header&gt;</code></td> <td style="text-align:center;">页眉</td> <td style="text-align:left;">介绍性的内容</td></tr> <tr><td style="text-align:center;"><code>&lt;footer&gt;</code></td> <td style="text-align:center;">页脚</td> <td style="text-align:left;">通常包含有关作者的信息版权文件链接</td></tr> <tr><td style="text-align:center;"><code>&lt;nav&gt;</code></td> <td style="text-align:center;">导航链接</td> <td style="text-align:left;">可以是当前文档内的，也可以是其他文档的索引。</td></tr> <tr><td style="text-align:center;"><code>&lt;main&gt;</code></td> <td style="text-align:center;">文档主内容</td> <td style="text-align:left;">中心主题直接相关或扩展的内容</td></tr> <tr><td style="text-align:center;"><code>&lt;article&gt;</code></td> <td style="text-align:center;">文章</td> <td style="text-align:left;">自成一体，独立分发，可重复使用</td></tr> <tr><td style="text-align:center;"><code>&lt;section&gt;</code></td> <td style="text-align:center;">文档中的节</td> <td style="text-align:left;"></td></tr> <tr><td style="text-align:center;"><code>&lt;aside&gt;</code></td> <td style="text-align:center;">页面内容外的内容</td> <td style="text-align:left;">其内容与文档的主要内容只有间接的关系。经常以边栏或呼出框的形式出现</td></tr> <tr><td style="text-align:center;"><code>&lt;mark&gt;</code></td> <td style="text-align:center;">重要或强调的文本</td> <td style="text-align:left;">为参考或记事目的而被标记或突出的文本，表面其相关性和重要性</td></tr> <tr><td style="text-align:center;"><code>&lt;summary&gt;</code></td> <td style="text-align:center;"><code>&lt;details&gt;</code>的标题</td> <td style="text-align:left;">为<code>&lt;details&gt;</code>指定一个摘要、标题或图例。点击<code>&lt;summary&gt;</code>可以切换details的打开或关闭</td></tr> <tr><td style="text-align:center;"><code>&lt;details&gt;</code></td> <td style="text-align:center;">用户能够查看或隐藏的额外细节</td> <td style="text-align:left;">其中的信息只有被切换到“打开”状态才可见。必须使用<code>&lt;summary&gt;</code>提供一个摘要或标签</td></tr> <tr><td style="text-align:center;"><code>&lt;figure&gt;</code></td> <td style="text-align:center;">自包含内容</td> <td style="text-align:left;">独立的内容，用<code>&lt;figcaption&gt;</code>元素指定一个可选的标题。比如图片、图标、照片、代码清单等</td></tr> <tr><td style="text-align:center;"><code>&lt;figcaption&gt;</code></td> <td style="text-align:center;"><code>&lt;figure&gt;</code>的标题</td> <td style="text-align:left;">描述其父元素</td></tr> <tr><td style="text-align:center;"><code>&lt;time&gt;</code></td> <td style="text-align:center;">定义时间/日期</td> <td style="text-align:left;">将日期翻译成机器可读的格式，以便获得更好的搜索引擎结果</td></tr></tbody></table> <h2 id="_4-块元素与行内元素"><a href="#_4-块元素与行内元素" class="header-anchor">#</a> 4. 块元素与行内元素</h2> <p><strong>块元素（block element)</strong></p> <ul><li>在网页中一般通过块元素来对页面进行布局</li></ul> <p><strong>行内元素（inline element）</strong></p> <ul><li><p>行内元素主要用来包裹文字</p></li> <li><p>一般情况下会在块元素中放行内元素，而不会在行内元素中放块元素</p></li> <li><p>如<code>&lt;p&gt;</code>元素中不能放任何块元素</p></li></ul> <h2 id="_5-内容修正"><a href="#_5-内容修正" class="header-anchor">#</a> 5. 内容修正</h2> <p>浏览器在解析网页时，会自动对网页中不符合规范的内容进行修正，比如</p> <ul><li><p>标签写在根元素的外部</p></li> <li><p><code>&lt;p&gt;</code>元素中嵌套了块元素</p></li> <li><p>根元素中出现了除<code>head</code>和<code>body</code>以外的子元素</p></li></ul> <p>通过浏览器中的<strong>查看网页源代码</strong>并不能看到修正效果，而使用检查进入<strong>开发者调试</strong>可以看到被修正后的结果。</p> <p>不过虽然浏览器能够对不规范的页面内容进行修正，但是还是建议编写正规的代码，以利于后期代码维护和团队代码写作。</p> <h2 id="_6-布局标签"><a href="#_6-布局标签" class="header-anchor">#</a> 6. 布局标签</h2> <p><strong>结构化语义标签</strong></p> <ul><li><code>header</code> 表示网页的头部（页眉）</li> <li><code>main</code>表示网页的主体部分（一个页面一个main）</li> <li><code>footer</code> 表示网页的底部（页脚）</li> <li><code>nav</code> 表示网页中的导航</li> <li><code>aside</code> 和主体相关的其他内容（侧边栏）</li> <li><code>aricle</code>表示一个独立的文章</li> <li><code>section</code> 表示一个独立的区块，上边的标签都不能表示时使用section</li></ul> <p><img src="https://hasakwebblogimg.oss-cn-hangzhou.aliyuncs.com/202211101952719.png" alt="布局标签"></p> <ul><li><code>div</code> 块元素，没有任何语义，表示一个区块，是主要的布局元素</li> <li><code>span</code>行内元素，没有任何语义，一般用于在网页中选中文字</li></ul> <h2 id="_7-列表"><a href="#_7-列表" class="header-anchor">#</a> 7. 列表</h2> <p>在html中可以创建三种列表</p> <p>1.有序列表，使用<code>ol</code>标签来创建有序列表，以<code>li</code>表示列表项</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ol</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>铅笔<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>橡皮<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>尺子<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>ol</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ol><li>铅笔</li> <li>橡皮</li> <li>尺子</li></ol> <p>2.无序列表，使用<code>ul</code>标签来创建无序列表，使用<code>li</code>表示列表项，可以看出列表元素之间是可以相互嵌套的</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ul</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>结构<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>表现<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>行为<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>ul</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>结构</li> <li>表现</li> <li>行为</li></ul> <ol start="3"><li><p>定义列表，使用 <code>dl</code>标签来创建定义列表，使用<code>dt</code>表示定义的内容，使用<code>dd</code>来对内容进行解释说明</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dl</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dt</span><span class="token punctuation">&gt;</span></span>结构<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dt</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dd</span><span class="token punctuation">&gt;</span></span>网页的结构，规定了那里是标题，那里是段落<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dd</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dt</span><span class="token punctuation">&gt;</span></span>表现<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dt</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dd</span><span class="token punctuation">&gt;</span></span>网页的样式<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dd</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dl</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><dl><dt>结构</dt> <dd>网页的结构，规定了那里是标题，那里是段落</dd> <dt>表现</dt> <dd>网页的样式</dd></dl></li></ol> <h2 id="_8-超链接"><a href="#_8-超链接" class="header-anchor">#</a> 8. 超链接</h2> <p>超链接可以让我们从一个页面跳转到其他页面，或者是当前页面的其他位置，使用<code>a</code>标签来定义一个超链接， <code>href</code>属性指定跳转的目标路径。超链接也是一个行内元素，在<code>a</code>标签中可以嵌套除他自身外的任何元素。</p> <p><strong>外部地址</strong></p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ul</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://www.baidu.com<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>链接一个绝对路径<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>mailto:example@outlook.com<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>链接一个email地址<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>tel：+123456789<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>链接一个电话号码<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>ul</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li><a href="https://www.baidu.com">链接一个绝对路径</a></li> <li><a href="mailto:example@outlook.com">链接一个email地址</a></li> <li><a href="tel：+123456789">链接一个电话号码</a></li></ul>
**内部地址**
<p>当我们需要跳转一个服务器内部的页面时，一般我们都会使用相对路径，会以<code>./</code>或<code>../</code>开头</p> <ul><li><code>./</code>表示当前文件所在目录，可以省略不写</li> <li><code>../</code>表示当前文件所在目录的上一级目录</li></ul> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./test1.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>../test2.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./test3/test3.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>../test4/test4.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>新建页面</strong></p> <p><code>target</code>属性，用来指定超链接打开的位置可选值：</p> <ul><li><code>_self</code>在当前页面中打开超链接，默认值</li> <li><code>_blank</code>在新建页面打开超链接</li></ul> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./test1.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接1——默认<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./test1.html<span class="token punctuation">&quot;</span></span> <span class="token attr-name">target</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_self<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接1——当前页面<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./test1.html<span class="token punctuation">&quot;</span></span> <span class="token attr-name">target</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_blank<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>超链接1——新建页面<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p><strong>锚点跳转</strong></p> <p>可以直接将超链接的<code>href</code>属性设置为 <code>#</code>，这样点击超链接后页面跳转到当前页面的顶部位置。</p> <p>可以跳转到页面的指定位置（锚点），只需将<code>href</code>属性设置为**#目标元素的id属性值**（唯一不可重复）</p> <p>​	开发中，也可以将<code>#</code>作为超链接的路径占位符使用</p> <p>​	也可以使用<code>javascript:;</code>来作为<code>href</code>的属性值，此时点击这个超链接什么都不会发生</p> <h2 id="_9-图片"><a href="#_9-图片" class="header-anchor">#</a> 9. 图片</h2> <p>图片标签用于向当前页面中引入一个外部图片</p> <p><code>&lt;img&gt;</code>标签是一个自结束标签，这种元素属于<strong>替换元素</strong>（块和行内元素之间，具有两种元素的的特点）</p> <p><strong>属性</strong></p> <ul><li><p><code>src</code> ：属性指定的是外部图片的路径</p></li> <li><p><code>alt</code>: 图片的描述，默认情况下不会显示，有些浏览器会在图片无法加载时显示，搜索引擎会根据alt中的内容来识别图片。</p></li> <li><p><code>width</code>: 图片的宽度（单位是像素）</p></li> <li><p><code>height</code>: 图片的高度（单位是像素）</p> <blockquote><p>宽度和高度中如果修改一个，则另一个会等比例缩放</p></blockquote></li></ul> <p><strong>注意</strong></p> <ol><li>一般在pc端，不建议修改图片大小，需要多大的图片就裁多大</li> <li>在移动端，经常需要对图片进行缩放（大图缩小）</li></ol> <p><strong>图片格式</strong></p> <p><strong>jpge(jpg)</strong></p> <ul><li>支持的颜色比较丰富</li> <li>不支持透明效果</li> <li>不支持动图</li> <li>一般用来显示照片</li></ul> <p><strong>gif</strong></p> <ul><li>支持的颜色比较单一</li> <li>支持简单透明</li> <li>支持动图</li></ul> <p><strong>png</strong></p> <ul><li>支持的颜色丰富</li> <li>支持复杂透明</li> <li>不支持动图</li> <li>专为网页而生</li></ul> <p><strong>webp</strong></p> <ul><li>是谷歌新推出的专门用于表示网页中的图片的一种格式</li> <li>具备其他图片格式的所有优点，且文件小</li> <li>缺点：兼容性不好</li></ul> <p><strong>base64</strong></p> <ul><li>将图片使用base64编码，这样可以将图片转换为字符，通过字符的形式来引入图片</li> <li>好处是不需要像上面获取图片得发送请求，加载速度快</li></ul> <p><strong>使用原则</strong></p> <ul><li>图片大小一样，选文件小的</li> <li>图片效果不一样，选图片效果好的</li> <li>尽可能的兼顾和平衡图片效果和文件大小</li></ul> <h2 id="_10-内联格式"><a href="#_10-内联格式" class="header-anchor">#</a> 10.内联格式</h2> <p>内联框架<code>iframe</code>, 用于向当前页面中引入一个其他页面</p> <ul><li><code>src</code>指定要引入的网页的路径</li> <li><code>frameborder</code>指定内联框架的边框</li></ul> <h2 id="_11-音视频"><a href="#_11-音视频" class="header-anchor">#</a> 11. 音视频</h2> <p><strong>音频</strong></p> <p><code>audio</code>标签用来向页面中引入一个外部的音频文件，音频文件引入时，默认不允许用户自己控制播放停止。</p> <p><strong>属性</strong></p> <ul><li><p><code>controls</code> 是否允许用户控制播放</p></li> <li><p><code>autoplay</code> 音频文件是否自动播放</p></li> <li><p>如果设置了<code>autoplay</code>,则在音乐打开页面时会自动播放，但是目前大部分浏览器都不会自动播放</p></li> <li><p><code>loop</code> 音频文件是否循环播放</p></li></ul> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>audio</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./source/audio.mp3<span class="token punctuation">&quot;</span></span> <span class="token attr-name">controls</span> <span class="token attr-name">autoplay</span> <span class="token attr-name">loop</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>audio</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li><p><code>source</code>除了通过<code>src</code>属性来指定外部文件的路径外，还可以通过<code>&lt;source&gt;</code>元素来指定文件的路径。</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>audio</span> <span class="token attr-name">controls</span> <span class="token attr-name">autoplay</span> <span class="token attr-name">loop</span><span class="token punctuation">&gt;</span></span>
	对不起，您的浏览器不支持播放音频！请升级浏览器!
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>source</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./source/audio.mp3<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>source</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./source/audio.ogg<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>audio</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><strong>embed</strong></p> <p>IE8下不支持<code>audio</code>元素，但是可以使用 <code>&lt;embed&gt;</code>元素在文档中的指定位置潜入外部内容，这个内容是由外部应用程序或其他互动内容的来源提供的，如浏览器插件。</p></li></ul> <p><strong>视频</strong></p> <p>使用 <code>video</code>标签来向网页中引入一个视频，使用方式和 <code>audio</code>基本是一样的</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>video</span> <span class="token attr-name">controls</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>source</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://xxxxxxx.webm<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>video/webm<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>source</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://xxxxxxx.mp4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>video/mp4<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>embed</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://xxxxxxx.mp4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>video/mp4<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>video</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><strong>其他</strong></p> <p>通过<code>iframe</code> 和<code>embed</code> 的方式引入视频，有些网站提供了视频连接的HTML代码和通用代码，不过<code>embed</code>需要flash支持，而flash以及不再使用了</p></div></section> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/blogs/基础/html/20221107html02.html">
          02 CSS语法与选择器
        </a></span></p></div> <div class="comments-wrapper"><!----></div></main></div> <!----></div> <ul class="sub-sidebar sub-sidebar-wrapper" style="width:0;" data-v-b57cc07c data-v-7dd95ae2></ul></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div></div></div>
    <script src="/assets/js/app.c7915c77.js" defer></script><script src="/assets/js/3.f80332a6.js" defer></script><script src="/assets/js/1.5cffa4a1.js" defer></script><script src="/assets/js/11.c5238d8f.js" defer></script>
  </body>
</html>
